希望能给大家带来帮助,请只做参考用,主要是请看11个计算的步骤注释说明。
1
///
<summary>
2 /// 计算工资算法
3 /// </summary>
4 /// <param name="departmentID"> 部门主键 </param>
5 /// <param name="targetYearMonth"> 目标年月 </param>
6 /// <returns> 影响的行数 </returns>
7 public int Calculate(String departmentID, String targetYearMonth)
8 {
9 int returnValue = 0 ;
10 BaseParameterDao parameterDao = new BaseParameterDao( this .DbHelper, this .UserInfo);
11 String qiZhengE = parameterDao.GetParameter( " System " , " SalaryPersonalIncomeTax " , " QiZhengE " );
12 String year = targetYearMonth.Substring( 0 , 4 );
13 String month = targetYearMonth.Substring( 5 );
14 DataTable dataTable = this .SearchByDepartment(departmentID, year, month, false );
15 // 01 检查个人所得税起征额是否为空的?
16 this .CheckPersonalIncomeTax(dataTable, qiZhengE);
17 // 02 税前应加项合计
18 this .GetSum(dataTable, " 税前应加项目 " , BaseSalaryTable.FieldShuiQianYingJiaXiang);
19 // 03 税前应扣项合计
20 this .GetSum(dataTable, " 税前应扣项目 " , BaseSalaryTable.FieldShuiQianYingKouXiang);
21 // 04 基金补贴保险类合计,例如三金
22 this .GetSum(dataTable, " 基金保险补贴类 " , BaseSalaryTable.FieldJiJinBaoXianBuTieLei);
23 // 05 纳税项合计[记税工资,是否纳税项目来计算]
24 this .GetSalaryTax(dataTable);
25 // 06 计算个人所得税相关数据
26 this .GetPersonalIncomeTax(dataTable);
27 // 07 计算应发工资
28 this .GetSalary(dataTable);
29 // 08 计算税后应扣项目
30 this .GetSum(dataTable, " 税后代加项目 " , BaseSalaryTable.FieldShuiHouDaiJiaXiang);
31 // 09 计算税后应加项目
32 this .GetSum(dataTable, " 税后代扣项目 " , BaseSalaryTable.FieldShuiHouDaiKouXiang);
33 // 10 计算实发工资
34 this .GetRealSalary(dataTable);
35 // 11 将计算结果保存到数据库
36 BaseSalaryEntity salaryEntity = null ;
37 BaseSalaryDao salaryDao = new BaseSalaryDao( this .DbHelper, this .UserInfo);
38 foreach (DataRow dataRow in dataTable.Rows)
39 {
40 if (dataRow.RowState == DataRowState.Modified)
41 {
42 salaryEntity = new BaseSalaryEntity(dataRow);
43 returnValue += salaryDao.UpdateEntity(salaryEntity);
44 }
45 }
46 return returnValue;
47 }
48
2 /// 计算工资算法
3 /// </summary>
4 /// <param name="departmentID"> 部门主键 </param>
5 /// <param name="targetYearMonth"> 目标年月 </param>
6 /// <returns> 影响的行数 </returns>
7 public int Calculate(String departmentID, String targetYearMonth)
8 {
9 int returnValue = 0 ;
10 BaseParameterDao parameterDao = new BaseParameterDao( this .DbHelper, this .UserInfo);
11 String qiZhengE = parameterDao.GetParameter( " System " , " SalaryPersonalIncomeTax " , " QiZhengE " );
12 String year = targetYearMonth.Substring( 0 , 4 );
13 String month = targetYearMonth.Substring( 5 );
14 DataTable dataTable = this .SearchByDepartment(departmentID, year, month, false );
15 // 01 检查个人所得税起征额是否为空的?
16 this .CheckPersonalIncomeTax(dataTable, qiZhengE);
17 // 02 税前应加项合计
18 this .GetSum(dataTable, " 税前应加项目 " , BaseSalaryTable.FieldShuiQianYingJiaXiang);
19 // 03 税前应扣项合计
20 this .GetSum(dataTable, " 税前应扣项目 " , BaseSalaryTable.FieldShuiQianYingKouXiang);
21 // 04 基金补贴保险类合计,例如三金
22 this .GetSum(dataTable, " 基金保险补贴类 " , BaseSalaryTable.FieldJiJinBaoXianBuTieLei);
23 // 05 纳税项合计[记税工资,是否纳税项目来计算]
24 this .GetSalaryTax(dataTable);
25 // 06 计算个人所得税相关数据
26 this .GetPersonalIncomeTax(dataTable);
27 // 07 计算应发工资
28 this .GetSalary(dataTable);
29 // 08 计算税后应扣项目
30 this .GetSum(dataTable, " 税后代加项目 " , BaseSalaryTable.FieldShuiHouDaiJiaXiang);
31 // 09 计算税后应加项目
32 this .GetSum(dataTable, " 税后代扣项目 " , BaseSalaryTable.FieldShuiHouDaiKouXiang);
33 // 10 计算实发工资
34 this .GetRealSalary(dataTable);
35 // 11 将计算结果保存到数据库
36 BaseSalaryEntity salaryEntity = null ;
37 BaseSalaryDao salaryDao = new BaseSalaryDao( this .DbHelper, this .UserInfo);
38 foreach (DataRow dataRow in dataTable.Rows)
39 {
40 if (dataRow.RowState == DataRowState.Modified)
41 {
42 salaryEntity = new BaseSalaryEntity(dataRow);
43 returnValue += salaryDao.UpdateEntity(salaryEntity);
44 }
45 }
46 return returnValue;
47 }
48
本文转自 jirigala 51CTO博客,原文链接:http://blog.51cto.com/2347979/451629,如需转载请自行联系原作者