Browse Source

计算工资 4.2

leiy 1 year ago
parent
commit
eb59bb8fca
1 changed files with 42 additions and 21 deletions
  1. 42 21
      OASystem/OASystem.Api/OAMethodLib/PayrollComputation.cs

+ 42 - 21
OASystem/OASystem.Api/OAMethodLib/PayrollComputation.cs

@@ -65,7 +65,8 @@ namespace OASystem.API.OAMethodLib
                 _result.Msg = startDt + " - " + endDt + "请假 类型数据 获取失败!";
                 return _result;
             }
-            
+
+            _result.Msg = string.Empty;
             foreach (var pm_wsInfo in pm_WageSheetDattaSources)
             {
                 string itemName = userNames.Where(it => it.Id == pm_wsInfo.UserId).FirstOrDefault().CnName;
@@ -167,7 +168,7 @@ namespace OASystem.API.OAMethodLib
                 if (sp_leave_details.Count <= 0)
                 {
                     _result.Msg += startDt + " - " + endDt +"  "+itemName  + "  请假 审批数据获取未获取到!\r\n";
-                    continue;
+                    //continue;
                 }
 
                 List<Ex_Items> ex_Items = new List<Ex_Items>();//假勤 And 打卡备注集合
@@ -219,6 +220,21 @@ namespace OASystem.API.OAMethodLib
                             CalculateTypeFee(leaveType, date_Range.type, leave_starttime, leave_endtime, amountPayable, work_days, new_duration, 
                                 out leave_meals, out thisTypeDeduction);
 
+                            #region 累计类型扣款
+                            //1年假;2事假;3病假;4调休假;5婚假;6产假;7陪产假;8其他;9丧假
+
+                            if (leaveType == 2) //事假
+                            {
+                                personalLeaveTotal += thisTypeDeduction;
+                            }
+                            else if (leaveType == 3) //病假
+                            {
+
+                                sickLeaveTotal = thisTypeDeduction;
+                            }
+
+                            #endregion
+
                             meal_deduction += leave_meals;
                             string startEndTiime = startEndTiime = date_Range.new_begin_dt.ToString("yyyy-MM-dd HH:mm") + " - " + 
                                 date_Range.new_end_dt.ToString("yyyy-MM-dd HH:mm");
@@ -227,12 +243,12 @@ namespace OASystem.API.OAMethodLib
                             {
                                 SubTypeId = leaveType,
                                 SubType = typeName,
-                                StartTimeDt = date_Range.new_begin_dt,
-                                EndTimeDt = date_Range.new_end_dt,
+                                StartTimeDt = Convert.ToDateTime( date_Range.new_begin_dt.ToString("yyyy-MM-dd HH:mm:ss")),
+                                EndTimeDt = Convert.ToDateTime(date_Range.new_end_dt.ToString("yyyy-MM-dd HH:mm:ss")),
                                 Duration = new_duration,
                                 Deduction = thisTypeDeduction,
                                 //Reason = apply_data.reason,
-                                Apply_time_dt = sp_item.apply_time_dt,
+                                Apply_time_dt = Convert.ToDateTime(sp_item.apply_time_dt.ToString("yyyy-MM-dd HH:mm:ss")),
                                 //Approval_name = sp_item.approval_name,
                             };
                             ex_ItemInfos.Add(ex_Item);
@@ -433,6 +449,7 @@ namespace OASystem.API.OAMethodLib
                             List<Root> roots_words= checkInDayDataView.datas.Where(it => it.base_info.day_type == 0).ToList(); //获取工作日日报信息
                             List<Root> roots_exs = checkInDayDataView.datas.Where(it => it.exception_infos.Count > 0).ToList();
                             Root roots_ex = roots_exs.Where(it => it.base_info.dateDt == pc_ex_item.sch_checkin_time_dt).FirstOrDefault();
+                            if (roots_ex != null) { 
                             List<Exception_infos> exception_infos = roots_ex.exception_infos;
 
                             List<Exception_infos> exception_infos1 = checkInDayDataView.datas[29].exception_infos;
@@ -569,6 +586,7 @@ namespace OASystem.API.OAMethodLib
                                     }
                                 }
                             }
+                            }
                         }
                     }
                 }
@@ -678,11 +696,14 @@ namespace OASystem.API.OAMethodLib
         /// <param name="mealDeduction"></param>
         /// <param name="typeDeduction"></param>
         public static void CalculateTypeFee(int leaveType, string date_Range_type, string startTime, string endTime,decimal amountPayable,int work_days,
-            int duration, out decimal mealDeduction, out decimal typeDeduction)
+            decimal duration, out decimal mealDeduction, out decimal typeDeduction)
         {
             typeDeduction = 0;
             mealDeduction = 0;
 
+            //处理时长
+            if (duration == 7) duration = 7.50M;
+
             string am_starttime = "08:59";
             string am_endtime = "13:01";
 
@@ -709,26 +730,26 @@ namespace OASystem.API.OAMethodLib
                     }
                     else if (date_Range_type == "hour")
                     {
-                        int leave_halfHour = duration / Convert.ToInt32(0.5);
+                        decimal leave_halfHour = Convert.ToDecimal(duration) / Convert.ToDecimal(0.5);
                         typeDeduction = personalkLeave_dailywage_halfhour * leave_halfHour;
-                        if (duration >= 3) //单天请假三小时 && 请假时间在上午 则没有餐补
+                        if (duration >= 3 && duration <= 7.5M) //单天请假三小时 && 请假时间在上午 则没有餐补
                         {
                             //处理开始时间
                             if (startTime.CompareTo(am_starttime) > 0 && startTime.CompareTo(am_endtime) < 0)
                             {
                                 //处理结束时间
-                                if (endTime.CompareTo(am_starttime) > 0 && endTime.CompareTo(am_endtime) < 0)
+                                if (endTime.CompareTo(am_starttime) > 0 && endTime.CompareTo(am_endtime) > 0)
                                 {
                                     mealDeduction = 10; //餐补扣款
                                 }
                             }
                         }
-                        else if (duration > 7.5) //多天计算
+                        else if (duration > 7.5M) //多天计算
                         {
-                            int leave_halfHour1 = duration / Convert.ToInt32(0.5);
+                            decimal leave_halfHour1 = Convert.ToDecimal(duration) / Convert.ToDecimal(0.5);
                             typeDeduction = personalkLeave_dailywage_halfhour * leave_halfHour1;
 
-                            decimal leaveDays = Convert.ToDecimal(duration / 7.5);
+                            decimal leaveDays = duration / 7.5M;
                             if (leaveDays % 1 == 0)
                             {
                                 mealDeduction = 10 * leaveDays; //餐补扣款
@@ -765,9 +786,9 @@ namespace OASystem.API.OAMethodLib
                     }
                     else if (date_Range_type == "hour")
                     {
-                        int sickLeave_halfHour = duration / Convert.ToInt32(0.5);
+                        decimal sickLeave_halfHour = duration / 0.5M;
                         typeDeduction = sickLeave_dailywage_halfhour_deduction *sickLeave_halfHour ;
-                        if (duration >= 3 && duration <= 7.5) //单天请假三小时 && 请假时间在上午 则没有餐补
+                        if (duration >= 3 && duration <= 7.5M) //单天请假三小时 && 请假时间在上午 则没有餐补
                         {
                             //处理开始时间
                             if (startTime.CompareTo(am_starttime) > 0 && startTime.CompareTo(am_endtime) < 0)
@@ -779,12 +800,12 @@ namespace OASystem.API.OAMethodLib
                                 }
                             }
                         }
-                        else if (duration > 7.5) //多天计算
+                        else if (duration > 7.5M) //多天计算
                         {
-                            int sickLeave_halfHour1 = duration / Convert.ToInt32(0.5);
+                            decimal sickLeave_halfHour1 = duration / 0.5M;
                             typeDeduction = sickLeave_dailywage_halfhour_deduction * sickLeave_halfHour1;
 
-                            decimal leaveDays = Convert.ToDecimal(duration / 7.5);
+                            decimal leaveDays = Convert.ToDecimal(duration / 7.5M);
                             if (leaveDays % 1 == 0)
                             {
                                 mealDeduction = 10 * leaveDays; //餐补扣款
@@ -841,7 +862,7 @@ namespace OASystem.API.OAMethodLib
         /// <param name="endTime"></param>
         /// <param name="duration"></param>
         /// <param name="mealDeduction"></param>
-        public static void CalculateTypeFeeSub(string date_Range_type, string startTime, string endTime, int duration, out decimal mealDeduction)
+        public static void CalculateTypeFeeSub(string date_Range_type, string startTime, string endTime, decimal duration, out decimal mealDeduction)
         {
             mealDeduction = 0;
             string am_starttime = "08:59";
@@ -865,13 +886,13 @@ namespace OASystem.API.OAMethodLib
                         }
                     }
                 }
-                else if (duration >= 7 && duration <= 7.5 )
+                else if (duration >= 7 && duration <= 7.50M )
                 {
                     mealDeduction = 10; //餐补扣款
                 }
-                else if (duration >= 7.5) //多天计算
+                else if (duration >= 7.50M) //多天计算
                 {
-                    decimal leaveDays = Convert.ToDecimal(duration / 7.5);
+                    decimal leaveDays = Convert.ToDecimal(duration / 7.50M);
 
                     if (leaveDays % 1 == 0)
                     {