今天心血来潮,编写了一个个人所得税计算器,呵呵,虽然功能不是很强,而且也是重复造轮子(网上也有许多的个人所得税计算器),不过“纸上得来总觉浅,绝知此事要躬行”,自己动动手绝对有好处的。
下面是个人所得税计算的类:
下面是个人所得税计算的类:
1namespace SalaryComputer
2{
3 public class PersonalIncomeTax
4 {
5 字段/属性#region 字段/属性
6 /**//// <summary>
7 /// 税率
8 /// </summary>
9 private double[] taxRate = { 0, 0.05, 0.10, 0.15, 0.20, 0.25, 0.30, 0.35, 0.40, 0.45 };
10
11 /**//// <summary>
12 /// 税率(税率最好保存在数据库表里或xml文件,当国家出台新的个人所得税政策法规时,不需要修改代码部分)
13 /// </summary>
14 public double[] TaxRate
15 {
16 get { return taxRate; }
17 set { taxRate = value; }
18 }
19
20 /**//// <summary>
21 /// 速算扣除数
22 /// </summary>
23 private double[] subtractNumber = { 0, 0, 25, 125, 375, 1375, 3375, 6375, 10375, 15375 };
24
25 /**//// <summary>
26 /// 速算扣除数
27 /// </summary>
28 public double[] SubtractNumber
29 {
30 get { return subtractNumber; }
31 set { subtractNumber = value; }
32 }
33
34 /**//// <summary>
35 /// 超过起征税的数额
36 /// </summary>
37 private double[] surpassAmount = { 0, 500, 2000, 5000, 20000, 40000, 60000, 80000, 100000 };
38
39 /**//// <summary>
40 /// 超过起征税的数额
41 /// </summary>
42 public double[] SurpassAmount
43 {
44 get { return surpassAmount; }
45 set { surpassAmount = value; }
46 }
47
48 /**//// <summary>
49 /// 征税起点工资
50 /// </summary>
51 private double startTaxSalary;
52
53 /**//// <summary>
54 /// 征税起点工资
55 /// </summary>
56 public double StartTaxSalary
57 {
58 get { return startTaxSalary; }
59 set { startTaxSalary = value; }
60 }
61 #endregion
62
63 构造函数#region 构造函数
64 /**//// <summary>
65 /// 无参构造函数
66 /// </summary>
67 public PersonalIncomeTax()
68 {
69 StartTaxSalary = 2000;
70 }
71
72 /**//// <summary>
73 /// 征税基本工资有时会随国家政策,法律变更
74 /// </summary>
75 /// <param name="baseSalary">征税基本工资</param>
76 public PersonalIncomeTax(double taxSalary)
77 {
78 StartTaxSalary = taxSalary;
79 }
80 #endregion
81
82 自定义方法#region 自定义方法
83 /**//// <summary>
84 /// 计算个人所得税,返回应缴税收,征税后所得薪水
85 /// </summary>
86 /// <param name="Salary">薪水</param>
87 /// <param name="Welfare">五险一金数额</param>
88 /// <param name="IsChinaNationality">是否是中国国籍</param>
89 /// <param name="taxedSalary">税后所得实际工作</param>
90 /// <returns>返回个人所得税</returns>
91 public double CalculatePersonTax(double Salary, double Welfare, bool IsChinaNationality, out double taxedSalary)
92 {
93 double RateSalary = 0;
94
95 RateSalary = Salary - StartTaxSalary - Welfare;
96
97 if (!IsChinaNationality)
98 {
99 RateSalary = RateSalary - 3000;
100 }
101
102 int rateIndex = 0;
103
104 if (RateSalary >= 0)
105 {
106 for (int index = 0; index < SurpassAmount.Length; index++)
107 {
108 if (RateSalary >= SurpassAmount[index] && RateSalary <= SurpassAmount[index + 1])
109 {
110 rateIndex = index + 1;
111 break;
112 }
113 }
114 }
115
116 double rate = RateSalary * TaxRate[rateIndex] - SubtractNumber[rateIndex];
117 taxedSalary = Salary - Welfare - rate;
118
119 return rate;
120 }
121
122 #endregion
123 }
124}
125
2{
3 public class PersonalIncomeTax
4 {
5 字段/属性#region 字段/属性
6 /**//// <summary>
7 /// 税率
8 /// </summary>
9 private double[] taxRate = { 0, 0.05, 0.10, 0.15, 0.20, 0.25, 0.30, 0.35, 0.40, 0.45 };
10
11 /**//// <summary>
12 /// 税率(税率最好保存在数据库表里或xml文件,当国家出台新的个人所得税政策法规时,不需要修改代码部分)
13 /// </summary>
14 public double[] TaxRate
15 {
16 get { return taxRate; }
17 set { taxRate = value; }
18 }
19
20 /**//// <summary>
21 /// 速算扣除数
22 /// </summary>
23 private double[] subtractNumber = { 0, 0, 25, 125, 375, 1375, 3375, 6375, 10375, 15375 };
24
25 /**//// <summary>
26 /// 速算扣除数
27 /// </summary>
28 public double[] SubtractNumber
29 {
30 get { return subtractNumber; }
31 set { subtractNumber = value; }
32 }
33
34 /**//// <summary>
35 /// 超过起征税的数额
36 /// </summary>
37 private double[] surpassAmount = { 0, 500, 2000, 5000, 20000, 40000, 60000, 80000, 100000 };
38
39 /**//// <summary>
40 /// 超过起征税的数额
41 /// </summary>
42 public double[] SurpassAmount
43 {
44 get { return surpassAmount; }
45 set { surpassAmount = value; }
46 }
47
48 /**//// <summary>
49 /// 征税起点工资
50 /// </summary>
51 private double startTaxSalary;
52
53 /**//// <summary>
54 /// 征税起点工资
55 /// </summary>
56 public double StartTaxSalary
57 {
58 get { return startTaxSalary; }
59 set { startTaxSalary = value; }
60 }
61 #endregion
62
63 构造函数#region 构造函数
64 /**//// <summary>
65 /// 无参构造函数
66 /// </summary>
67 public PersonalIncomeTax()
68 {
69 StartTaxSalary = 2000;
70 }
71
72 /**//// <summary>
73 /// 征税基本工资有时会随国家政策,法律变更
74 /// </summary>
75 /// <param name="baseSalary">征税基本工资</param>
76 public PersonalIncomeTax(double taxSalary)
77 {
78 StartTaxSalary = taxSalary;
79 }
80 #endregion
81
82 自定义方法#region 自定义方法
83 /**//// <summary>
84 /// 计算个人所得税,返回应缴税收,征税后所得薪水
85 /// </summary>
86 /// <param name="Salary">薪水</param>
87 /// <param name="Welfare">五险一金数额</param>
88 /// <param name="IsChinaNationality">是否是中国国籍</param>
89 /// <param name="taxedSalary">税后所得实际工作</param>
90 /// <returns>返回个人所得税</returns>
91 public double CalculatePersonTax(double Salary, double Welfare, bool IsChinaNationality, out double taxedSalary)
92 {
93 double RateSalary = 0;
94
95 RateSalary = Salary - StartTaxSalary - Welfare;
96
97 if (!IsChinaNationality)
98 {
99 RateSalary = RateSalary - 3000;
100 }
101
102 int rateIndex = 0;
103
104 if (RateSalary >= 0)
105 {
106 for (int index = 0; index < SurpassAmount.Length; index++)
107 {
108 if (RateSalary >= SurpassAmount[index] && RateSalary <= SurpassAmount[index + 1])
109 {
110 rateIndex = index + 1;
111 break;
112 }
113 }
114 }
115
116 double rate = RateSalary * TaxRate[rateIndex] - SubtractNumber[rateIndex];
117 taxedSalary = Salary - Welfare - rate;
118
119 return rate;
120 }
121
122 #endregion
123 }
124}
125