Browse Source

薪资代码

yuansh 10 months ago
parent
commit
ec0bc24c75

+ 17 - 12
jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/salary/controller/SalaryChangeRecordController.java

@@ -162,18 +162,23 @@ public class SalaryChangeRecordController extends JeecgController<SalaryChangeRe
 
     public static void main(String[] args) {
 
-        String syHireType = "在职,离职";
-        String typeSql = "";
-        if(StringUtils.isNotBlank(syHireType)){
-            String[] types = syHireType.split(",");
-            for(String o:types){
-                typeSql = typeSql + ",'" + o + "'";
-            }
-        }
-        if(StringUtils.isNotBlank(typeSql)){
-            typeSql = "("+typeSql.substring(1)+")";
-        }
-        System.out.println(typeSql);
+        Date createTime = null;
+        createTime = new Date();
+        System.out.println(createTime);
+
+
+//        String syHireType = "在职,离职";
+//        String typeSql = "";
+//        if(StringUtils.isNotBlank(syHireType)){
+//            String[] types = syHireType.split(",");
+//            for(String o:types){
+//                typeSql = typeSql + ",'" + o + "'";
+//            }
+//        }
+//        if(StringUtils.isNotBlank(typeSql)){
+//            typeSql = "("+typeSql.substring(1)+")";
+//        }
+//        System.out.println(typeSql);
 //        queryWrapper.last("and IFNULL(sy_Hire_Type,'在职') !='离职' order by substring_index(work_no, '-', 1) + 0 asc,work_no asc");
 
 

+ 17 - 17
jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/salary/entity/SalaryManagementDetail.java

@@ -55,56 +55,56 @@ public class SalaryManagementDetail implements Serializable {
 	@Excel(name = "组织", width = 15)
 	private java.lang.String orgName;
 	/**基本薪资*/
-	@Excel(name = "基本薪资", width = 15)
+	@Excel(name = "基本薪资", width = 15,isStatistics=true)
 	private java.lang.String wages;
 	/**话费补贴*/
-	@Excel(name = "话费补贴", width = 15)
+	@Excel(name = "话费补贴", width = 15,isStatistics=true)
 	private java.math.BigDecimal phoneBill;
 	/**午餐补贴*/
-	@Excel(name = "午餐补贴", width = 15)
+	@Excel(name = "午餐补贴", width = 15,isStatistics=true)
 	private java.math.BigDecimal lunch;
 	/**住房补贴*/
-	@Excel(name = "住房补贴", width = 15)
+	@Excel(name = "住房补贴", width = 15,isStatistics=true)
 	private java.math.BigDecimal housingSubsidies;
 	/**交通补贴*/
-	@Excel(name = "交通补贴", width = 15)
+	@Excel(name = "交通补贴", width = 15,isStatistics=true)
 	private java.math.BigDecimal transportation;
 	/**全勤奖*/
-	@Excel(name = "全勤奖", width = 15)
+	@Excel(name = "全勤奖", width = 15,isStatistics=true)
 	private java.math.BigDecimal fullAttendance;
 	/**合计应发*/
-	@Excel(name = "合计应发", width = 15)
+	@Excel(name = "合计应发", width = 15,isStatistics=true)
 	private java.lang.String totalPayable;
 
 	/**社保*/
-	@Excel(name = "社保", width = 15)
+	@Excel(name = "社保", width = 15,isStatistics=true)
 	private java.math.BigDecimal socialSecurity;
 	/**公积金*/
-	@Excel(name = "公积金", width = 15)
+	@Excel(name = "公积金", width = 15,isStatistics=true)
 	private java.math.BigDecimal accumulationFund;
 	/**个税*/
-	@Excel(name = "个税", width = 15)
+	@Excel(name = "个税", width = 15,isStatistics=true)
 	private java.math.BigDecimal personalTax;
 	/**迟到扣费*/
-	@Excel(name = "迟到扣费", width = 15)
+	@Excel(name = "迟到扣费", width = 15,isStatistics=true)
 	private java.math.BigDecimal latenessCost;
 	/**事假扣费*/
-	@Excel(name = "事假扣费", width = 15)
+	@Excel(name = "事假扣费", width = 15,isStatistics=true)
 	private java.math.BigDecimal personalCost;
 	/**病假扣费*/
-	@Excel(name = "病假扣费", width = 15)
+	@Excel(name = "病假扣费", width = 15,isStatistics=true)
 	private java.math.BigDecimal sickCost;
 	/**婚假扣费*/
-	@Excel(name = "婚假扣费", width = 15)
+	@Excel(name = "婚假扣费", width = 15,isStatistics=true)
 	private java.math.BigDecimal marriageCost;
 	/**丧假扣费*/
-	@Excel(name = "丧假扣费", width = 15)
+	@Excel(name = "丧假扣费", width = 15,isStatistics=true)
 	private java.math.BigDecimal funeralCost;
 	/**合计应扣*/
-	@Excel(name = "合计应扣", width = 15)
+	@Excel(name = "合计应扣", width = 15,isStatistics=true)
 	private java.math.BigDecimal totalDeduction;
 	/**实发合计*/
-	@Excel(name = "实发合计", width = 15)
+	@Excel(name = "实发合计", width = 15,isStatistics=true)
 	private java.lang.String actualOccurrence;
 	/**工资抵扣*/
 	private java.math.BigDecimal deduction;

+ 2 - 2
jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/salary/entity/SalaryManagementExtra.java

@@ -57,10 +57,10 @@ public class SalaryManagementExtra implements Serializable {
 	/**年月*/
 	private String yearWithMonth;
 	/**税前工资(加密)*/
-    @Excel(name = "金额", width = 15)
+    @Excel(name = "金额", width = 15,isStatistics=true)
 	private String beforeTaxAmount;
 	/**税后工资(加密)*/
-    @Excel(name = "税后金额", width = 15)
+    @Excel(name = "税后金额", width = 15,isStatistics=true)
 	private String afterTaxAmount;
 	/**0福利现金 1年终奖*/
 	private String type;

+ 3 - 3
jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/salary/entity/SalaryManagementHoliday.java

@@ -73,13 +73,13 @@ public class SalaryManagementHoliday implements Serializable {
 //    @Excel(name = "版本", width = 15)
 	private String version;
 	/**个税*/
-    @Excel(name = "个税", width = 15)
+    @Excel(name = "个税", width = 15,isStatistics=true)
 	private java.math.BigDecimal personalTax;
 	/**应发薪资*/
-    @Excel(name = "应发薪资", width = 15)
+    @Excel(name = "应发薪资", width = 15,isStatistics=true)
 	private String wages;
 	/**实发合计*/
-    @Excel(name = "实发合计", width = 15)
+    @Excel(name = "实发合计", width = 15,isStatistics=true)
 	private String actualOccurrence;
 	/**应纳税所得额*/
 	private String payTaxes;

+ 4 - 3
jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/salary/entity/SalaryManagementWorkOvertime.java

@@ -80,13 +80,14 @@ public class SalaryManagementWorkOvertime implements Serializable {
 	/**十二月*/
 	private java.math.BigDecimal december;
 	/**加班工资*/
-    @Excel(name = "加班工资", width = 15)
+    @Excel(name = "加班工资", width = 15,isStatistics=true)
 	private java.math.BigDecimal workOvertimeCost;
 	/**个税*/
-    @Excel(name = "个税", width = 15)
+    @Excel(name = "个税", width = 15,isStatistics=true)
 	private java.math.BigDecimal personalTax;
 	/**实发合计*/
-    @Excel(name = "实发合计", width = 15)
+
+    @Excel(name = "实发合计", width = 15,isStatistics=true)
 	private String actualOccurrence;
 	/**工资抵扣*/
 	private java.math.BigDecimal deduction;

+ 123 - 29
jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/salary/service/impl/SalaryManagementServiceImpl.java

@@ -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{