|
@@ -651,6 +651,10 @@ public class SalaryManagementServiceImpl extends ServiceImpl<SalaryManagementMap
|
|
|
|
|
|
StringBuffer sb = new StringBuffer("本次执行(月度工资单):");//记录执行信息
|
|
|
|
|
|
+ String name = o.getName();//用户主键
|
|
|
+// if(name.equals("陈贤国")){
|
|
|
+// System.out.println("11111111");
|
|
|
+// }
|
|
|
String userId = o.getUserId();//用户主键
|
|
|
String orgName = o.getOrgName();//组织
|
|
|
String wages = o.getWages();//基本薪资
|
|
@@ -704,9 +708,13 @@ public class SalaryManagementServiceImpl extends ServiceImpl<SalaryManagementMap
|
|
|
salaryManagementDetail.setTransportation(o.getTransportation());
|
|
|
salaryManagementDetail.setFullAttendance(o.getFullAttendance());
|
|
|
|
|
|
+ //用于计算个税的累计金额 = 合计应发 - 合计应扣(除个税)
|
|
|
+ BigDecimal totalPriceAndTax = new BigDecimal("0");
|
|
|
+
|
|
|
//合计应发 = 基本薪资+话费补贴+午餐补贴+住房补贴+交通补贴+全勤奖
|
|
|
BigDecimal totalPayable = new BigDecimal("0");
|
|
|
totalPayable = bigWages.add(phoneBill).add(lunch).add(housingSubsidies).add(transportation).add(fullAttendance).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+
|
|
|
//合计应发 (密文)
|
|
|
String totalPayableText = AesEncryptUtil.encrypt(totalPayable.toString());
|
|
|
salaryManagementDetail.setTotalPayable(totalPayableText);//合计应发
|
|
@@ -745,9 +753,7 @@ public class SalaryManagementServiceImpl extends ServiceImpl<SalaryManagementMap
|
|
|
//应纳税所得额 = 合计应发 - 五险一金 - 5000 - 扣除数(考勤管理中的工资抵扣deduction) - 事假扣费 - 病假扣费 - 迟到扣费
|
|
|
BigDecimal payTaxes = new BigDecimal("0");
|
|
|
payTaxes = totalPayable.subtract(socialSecurity).subtract(accumulationFund).subtract(new BigDecimal("5000")).subtract(deduction)
|
|
|
- .subtract(personalCost).subtract(sickCost).subtract(latenessCost).setScale(2, BigDecimal.ROUND_HALF_UP);;
|
|
|
-
|
|
|
-
|
|
|
+ .subtract(personalCost).subtract(sickCost).subtract(latenessCost).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
|
|
|
|
|
|
//累计个税 = 本年度当前人员所有已缴纳个税
|
|
@@ -773,6 +779,8 @@ public class SalaryManagementServiceImpl extends ServiceImpl<SalaryManagementMap
|
|
|
hisPayTaxes = AesEncryptUtil.desEncrypt(hisPayTaxes).trim();
|
|
|
BigDecimal bigPayTaxes = new BigDecimal(hisPayTaxes);
|
|
|
extraTax = extraTax.add(bigPayTaxes);
|
|
|
+
|
|
|
+// totalPriceAndTax = totalPriceAndTax.add(bigPayTaxes);
|
|
|
// cumulative = cumulative.add(bigPayTaxes);上行已累计,此处无需累加
|
|
|
}
|
|
|
|
|
@@ -781,10 +789,10 @@ public class SalaryManagementServiceImpl extends ServiceImpl<SalaryManagementMap
|
|
|
sb.append(withMonth + "年度,此时之前(" + yearWithMonth + ")有效福利现金" + extra.size() + "条,共计金额"+extraTax+"已计入应纳税所得额与累计所得额中;");
|
|
|
payTaxes = payTaxes.add(extraTax);
|
|
|
|
|
|
- if(payTaxes.compareTo(BigDecimal.ZERO) < 0){
|
|
|
- sb.append("实际应纳税所得额为"+payTaxes+"故默认为0!!");
|
|
|
- payTaxes = new BigDecimal("0");
|
|
|
- }
|
|
|
+// if(payTaxes.compareTo(BigDecimal.ZERO) < 0){
|
|
|
+// sb.append("实际应纳税所得额为"+payTaxes+"故默认为0!!");
|
|
|
+// payTaxes = new BigDecimal("0");
|
|
|
+// }
|
|
|
|
|
|
String payTaxesText = AesEncryptUtil.encrypt(payTaxes.toString());
|
|
|
salaryManagementDetail.setPayTaxes(payTaxesText);//应纳税所得额
|
|
@@ -792,13 +800,25 @@ public class SalaryManagementServiceImpl extends ServiceImpl<SalaryManagementMap
|
|
|
if (cumulativeList.size() > 0) {
|
|
|
for (SalaryManagementDetail detail : cumulativeList) {
|
|
|
|
|
|
+ String hisGetTotalPayable = detail.getTotalPayable();//应发
|
|
|
+ hisGetTotalPayable = AesEncryptUtil.desEncrypt(hisGetTotalPayable).trim();
|
|
|
+
|
|
|
+ BigDecimal getTotalPayable = new BigDecimal(hisGetTotalPayable);//应发
|
|
|
+
|
|
|
+ BigDecimal totalDeduction = detail.getTotalDeduction();//应扣
|
|
|
+
|
|
|
+
|
|
|
BigDecimal personalTax = detail.getPersonalTax() == null ? BigDecimal.ZERO : detail.getPersonalTax();
|
|
|
+
|
|
|
+ //历史累计应纳税额 = 应发 - 应扣 + 个税(应扣中已包含个税,需再次加上)
|
|
|
+ totalPriceAndTax = getTotalPayable.subtract(totalDeduction).add(personalTax);
|
|
|
+
|
|
|
cumulativeTax = cumulativeTax.add(personalTax);//个税
|
|
|
|
|
|
- String hisPayTaxes = detail.getPayTaxes();//应纳税所得额
|
|
|
- hisPayTaxes = AesEncryptUtil.desEncrypt(hisPayTaxes).trim();
|
|
|
- BigDecimal bigPayTaxes = new BigDecimal(hisPayTaxes);
|
|
|
- cumulative = cumulative.add(bigPayTaxes);
|
|
|
+// String hisPayTaxes = detail.getPayTaxes();//应纳税所得额
|
|
|
+// hisPayTaxes = AesEncryptUtil.desEncrypt(hisPayTaxes).trim();
|
|
|
+// BigDecimal bigPayTaxes = new BigDecimal(hisPayTaxes);
|
|
|
+// cumulative = cumulative.add(bigPayTaxes);
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -813,7 +833,9 @@ public class SalaryManagementServiceImpl extends ServiceImpl<SalaryManagementMap
|
|
|
String hisPayTaxes = detail.getPayTaxes();
|
|
|
hisPayTaxes = AesEncryptUtil.desEncrypt(hisPayTaxes).trim();
|
|
|
BigDecimal bigPayTaxes = new BigDecimal(hisPayTaxes);
|
|
|
- cumulative = cumulative.add(bigPayTaxes);
|
|
|
+// cumulative = cumulative.add(bigPayTaxes);
|
|
|
+
|
|
|
+ totalPriceAndTax = totalPriceAndTax.add(bigPayTaxes);
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -828,19 +850,27 @@ public class SalaryManagementServiceImpl extends ServiceImpl<SalaryManagementMap
|
|
|
String hisPayTaxes = detail.getPayTaxes();
|
|
|
hisPayTaxes = AesEncryptUtil.desEncrypt(hisPayTaxes).trim();
|
|
|
BigDecimal bigPayTaxes = new BigDecimal(hisPayTaxes);
|
|
|
- cumulative = cumulative.add(bigPayTaxes);
|
|
|
+// cumulative = cumulative.add(bigPayTaxes);
|
|
|
+
|
|
|
+ totalPriceAndTax = totalPriceAndTax.add(bigPayTaxes);
|
|
|
}
|
|
|
}
|
|
|
sb.append(withMonth + "年度,此时之前(" + yearWithMonth + ")有效加班工资单" + cumulativeOvertimeList.size() + "条,已累计入累计所得额中;");
|
|
|
- cumulative = cumulative.add(payTaxes).setScale(2, BigDecimal.ROUND_HALF_UP);;
|
|
|
- String cumulativeText = AesEncryptUtil.encrypt(cumulative.toString());
|
|
|
+
|
|
|
+// cumulative = cumulative.add(payTaxes).setScale(2, BigDecimal.ROUND_HALF_UP);;
|
|
|
+ totalPriceAndTax = totalPriceAndTax.add(payTaxes).setScale(2, BigDecimal.ROUND_HALF_UP);;
|
|
|
+ cumulative = cumulative.add(totalPriceAndTax);
|
|
|
+
|
|
|
+ String cumulativeText = AesEncryptUtil.encrypt(totalPriceAndTax.toString());
|
|
|
salaryManagementDetail.setCumulative(cumulativeText);//累计所得额
|
|
|
|
|
|
//个税 = 累计所得额 * 对应税率 - 速算扣除数 - 累计税额 ===========================
|
|
|
BigDecimal personalTax = new BigDecimal("0");
|
|
|
|
|
|
- if(cumulative.compareTo(BigDecimal.ZERO) == 0){
|
|
|
- //如果应纳税额为0 则个税默认为0
|
|
|
+
|
|
|
+
|
|
|
+ if(cumulative.compareTo(BigDecimal.ZERO) <= 0){
|
|
|
+ //如果应纳税额为小于等于 则个税默认为0
|
|
|
}else{
|
|
|
if (top36000.compareTo(cumulative) != -1) { //top36000 >= cumulative
|
|
|
personalTax = cumulative.multiply(tax003).subtract(cumulativeTax);
|
|
@@ -1039,17 +1069,48 @@ public class SalaryManagementServiceImpl extends ServiceImpl<SalaryManagementMap
|
|
|
List<SalaryManagementWorkOvertime> cumulativeOvertimeList = salaryManagementWorkOvertimeMapper.selectByUser(userId, newYear, null);
|
|
|
|
|
|
if (cumulativeList.size() > 0) {
|
|
|
+
|
|
|
+ BigDecimal deduction = new BigDecimal("0");
|
|
|
+ Date createTime = null;
|
|
|
+
|
|
|
+ for (SalaryManagementDetail detail : cumulativeList) {
|
|
|
+ Date createTime1 = detail.getCreateTime();
|
|
|
+ BigDecimal deduction1 = detail.getDeduction() == null ? BigDecimal.ZERO : detail.getDeduction();
|
|
|
+
|
|
|
+ if(createTime == null){
|
|
|
+ createTime = createTime1;
|
|
|
+ deduction = deduction1;
|
|
|
+ }else{
|
|
|
+
|
|
|
+ if(createTime.before(createTime1)){
|
|
|
+ createTime = createTime1;
|
|
|
+ deduction = deduction1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
for (SalaryManagementDetail detail : cumulativeList) {
|
|
|
|
|
|
BigDecimal personalTax = detail.getPersonalTax() == null ? BigDecimal.ZERO : detail.getPersonalTax();
|
|
|
cumulativeTax = cumulativeTax.add(personalTax);//个税
|
|
|
|
|
|
- String hisPayTaxes = detail.getPayTaxes();
|
|
|
- hisPayTaxes = AesEncryptUtil.desEncrypt(hisPayTaxes).trim();
|
|
|
- BigDecimal bigPayTaxes = new BigDecimal(hisPayTaxes);
|
|
|
- cumulative = cumulative.add(bigPayTaxes);
|
|
|
- }
|
|
|
+ String hisGetTotalPayable = detail.getTotalPayable();//应发
|
|
|
+ hisGetTotalPayable = AesEncryptUtil.desEncrypt(hisGetTotalPayable).trim();
|
|
|
+
|
|
|
+ BigDecimal getTotalPayable = new BigDecimal(hisGetTotalPayable);//应发
|
|
|
|
|
|
+ BigDecimal totalDeduction = detail.getTotalDeduction();//应扣
|
|
|
+
|
|
|
+ //历史累计应纳税额 = 应发 - 应扣 + 个税(应扣中已包含个税,需再次加上)
|
|
|
+ cumulative = cumulative.add(getTotalPayable.subtract(totalDeduction).add(personalTax));
|
|
|
+
|
|
|
+// String hisPayTaxes = detail.getPayTaxes();
|
|
|
+// hisPayTaxes = AesEncryptUtil.desEncrypt(hisPayTaxes).trim();
|
|
|
+// BigDecimal bigPayTaxes = new BigDecimal(hisPayTaxes);
|
|
|
+// cumulative = cumulative.add(bigPayTaxes);
|
|
|
+ }
|
|
|
+ cumulative = cumulative.subtract(deduction);
|
|
|
}
|
|
|
sb.append(withMonth + "年度,此时之前(" + newYear + ")有效月度工资单" + cumulativeList.size() + "条,已累计入累计所得额中;");
|
|
|
|
|
@@ -1076,7 +1137,7 @@ public class SalaryManagementServiceImpl extends ServiceImpl<SalaryManagementMap
|
|
|
|
|
|
//个税 ===========================
|
|
|
BigDecimal personalTax = new BigDecimal("0");
|
|
|
- if(cumulative.compareTo(BigDecimal.ZERO) == 0){
|
|
|
+ if(cumulative.compareTo(BigDecimal.ZERO) <= 0){
|
|
|
//如果应纳税额为0 则个税默认为0
|
|
|
}else{
|
|
|
if (top36000.compareTo(cumulative) != -1) { //top36000 >= cumulative
|
|
@@ -1261,17 +1322,50 @@ public class SalaryManagementServiceImpl extends ServiceImpl<SalaryManagementMap
|
|
|
List<SalaryManagementHoliday> holidayList = salaryManagementHolidayMapper.selectByUser(userId,withMonth);
|
|
|
|
|
|
if (cumulativeList.size() > 0) {
|
|
|
+
|
|
|
+ BigDecimal deduction = new BigDecimal("0");
|
|
|
+ Date createTime = null;
|
|
|
+
|
|
|
+ for (SalaryManagementDetail detail : cumulativeList) {
|
|
|
+ Date createTime1 = detail.getCreateTime();
|
|
|
+ BigDecimal deduction1 = detail.getDeduction() == null ? BigDecimal.ZERO : detail.getDeduction();;
|
|
|
+
|
|
|
+ if(createTime == null){
|
|
|
+ createTime = createTime1;
|
|
|
+ deduction = deduction1;
|
|
|
+ }else{
|
|
|
+
|
|
|
+ if(createTime.before(createTime1)){
|
|
|
+ createTime = createTime1;
|
|
|
+ deduction = deduction1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
for (SalaryManagementDetail detail : cumulativeList) {
|
|
|
|
|
|
BigDecimal personalTax = detail.getPersonalTax() == null ? BigDecimal.ZERO : detail.getPersonalTax();
|
|
|
cumulativeTax = cumulativeTax.add(personalTax);//个税
|
|
|
|
|
|
- String hisPayTaxes = detail.getPayTaxes();
|
|
|
- hisPayTaxes = AesEncryptUtil.desEncrypt(hisPayTaxes).trim();
|
|
|
- BigDecimal bigPayTaxes = new BigDecimal(hisPayTaxes);
|
|
|
- cumulative = cumulative.add(bigPayTaxes);
|
|
|
- }
|
|
|
+ cumulativeTax = cumulativeTax.add(personalTax);//个税
|
|
|
+
|
|
|
+ String hisGetTotalPayable = detail.getTotalPayable();//应发
|
|
|
+ hisGetTotalPayable = AesEncryptUtil.desEncrypt(hisGetTotalPayable).trim();
|
|
|
+
|
|
|
+ BigDecimal getTotalPayable = new BigDecimal(hisGetTotalPayable);//应发
|
|
|
|
|
|
+ BigDecimal totalDeduction = detail.getTotalDeduction();//应扣
|
|
|
+
|
|
|
+ //历史累计应纳税额 = 应发 - 应扣 + 个税(应扣中已包含个税,需再次加上)
|
|
|
+ cumulative = cumulative.add(getTotalPayable.subtract(totalDeduction).add(personalTax));
|
|
|
+
|
|
|
+// String hisPayTaxes = detail.getPayTaxes();
|
|
|
+// hisPayTaxes = AesEncryptUtil.desEncrypt(hisPayTaxes).trim();
|
|
|
+// BigDecimal bigPayTaxes = new BigDecimal(hisPayTaxes);
|
|
|
+// cumulative = cumulative.add(bigPayTaxes);
|
|
|
+ }
|
|
|
+ cumulative = cumulative.subtract(deduction);
|
|
|
}
|
|
|
sb.append(withMonth + "年度,此时之前(" + yearWithMonth + ")有效月度工资单" + cumulativeList.size() + "条,已累计入累计所得额中;");
|
|
|
|
|
@@ -1315,7 +1409,7 @@ public class SalaryManagementServiceImpl extends ServiceImpl<SalaryManagementMap
|
|
|
//个税 ===========================
|
|
|
BigDecimal personalTax = new BigDecimal("0");
|
|
|
|
|
|
- if(cumulative.compareTo(BigDecimal.ZERO) == 0){
|
|
|
+ if(cumulative.compareTo(BigDecimal.ZERO) <= 0){
|
|
|
//如果应纳税额为0 则个税默认为0
|
|
|
}else{
|
|
|
|